home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / grafik programme / xv218 / docs / bmp.doc < prev    next >
Text File  |  1996-04-07  |  39KB  |  1,040 lines

  1. Note: the constants BI_RGB, BI_RLE8, and BI_RLE4 have the values 0, 1, and 2,
  2.     respectively.
  3.  
  4. =============================================================================
  5. Graphics File Formats
  6.  
  7. This topic describes the graphics-file formats used by the Microsoft Windows
  8. operating system. Graphics files include bitmap files, icon-resource files,
  9. and cursor-resource files.
  10.  
  11. Bitmap-File Formats
  12.  
  13. Windows bitmap files are stored in a device-independent bitmap (DIB) format
  14. that allows Windows to display the bitmap on any type of display device. The
  15. term "device independent" means that the bitmap specifies pixel color in a
  16. form independent of the method used by a display to represent color. The
  17. default filename extension of a Windows DIB file is .BMP.
  18.  
  19. Bitmap-File Structures
  20.  
  21. Each bitmap file contains a bitmap-file header, a bitmap-information header,
  22. a color table, and an array of bytes that defines the bitmap bits. The file
  23. has the following form:
  24.  
  25. BITMAPFILEHEADER bmfh;
  26. BITMAPINFOHEADER bmih;
  27. RGBQUAD          aColors[];
  28. BYTE             aBitmapBits[];
  29.  
  30. The bitmap-file header contains information about the type, size, and layout
  31. of a device-independent bitmap file. The header is defined as a
  32. BITMAPFILEHEADER structure.
  33.  
  34. The bitmap-information header, defined as a BITMAPINFOHEADER structure,
  35. specifies the dimensions, compression type, and color format for the bitmap.
  36.  
  37. The color table, defined as an array of RGBQUAD structures, contains as many
  38. elements as there are colors in the bitmap. The color table is not present
  39. for bitmaps with 24 color bits because each pixel is represented by 24-bit
  40. red-green-blue (RGB) values in the actual bitmap data area. The colors in the
  41. table should appear in order of importance. This helps a display driver
  42. render a bitmap on a device that cannot display as many colors as there are
  43. in the bitmap. If the DIB is in Windows version 3.0 or later format, the
  44. driver can use the biClrImportant member of the BITMAPINFOHEADER structure to
  45. determine which colors are important.
  46.  
  47. The BITMAPINFO structure can be used to represent a combined
  48. bitmap-information header and color table.  The bitmap bits, immediately
  49. following the color table, consist of an array of BYTE values representing
  50. consecutive rows, or "scan lines," of the bitmap. Each scan line consists of
  51. consecutive bytes representing the pixels in the scan line, in left-to-right
  52. order. The number of bytes representing a scan line depends on the color
  53. format and the width, in pixels, of the bitmap. If necessary, a scan line
  54. must be zero-padded to end on a 32-bit boundary. However, segment boundaries
  55. can appear anywhere in the bitmap. The scan lines in the bitmap are stored
  56. from bottom up. This means that the first byte in the array represents the
  57. pixels in the lower-left corner of the bitmap and the last byte represents
  58. the pixels in the upper-right corner.
  59.  
  60. The biBitCount member of the BITMAPINFOHEADER structure determines the number
  61. of bits that define each pixel and the maximum number of colors in the
  62. bitmap. These members can have any of the following values:
  63.  
  64. Value    Meaning
  65.  
  66. 1    Bitmap is monochrome and the color table contains two entries. Each
  67. bit in the bitmap array represents a pixel. If the bit is clear, the pixel is
  68. displayed with the color of the first entry in the color table. If the bit is
  69. set, the pixel has the color of the second entry in the table.
  70.  
  71. 4    Bitmap has a maximum of 16 colors. Each pixel in the bitmap is
  72. represented by a 4-bit index into the color table. For example, if the first
  73. byte in the bitmap is 0x1F, the byte represents two pixels. The first pixel
  74. contains the color in the second table entry, and the second pixel contains
  75. the color in the sixteenth table entry.
  76.  
  77. 8    Bitmap has a maximum of 256 colors. Each pixel in the bitmap is
  78. represented by a 1-byte index into the color table. For example, if the first
  79. byte in the bitmap is 0x1F, the first pixel has the color of the
  80. thirty-second table entry.
  81.  
  82. 24    Bitmap has a maximum of 2^24 colors. The bmiColors (or bmciColors)
  83. member is NULL, and each 3-byte sequence in the bitmap array represents the
  84. relative intensities of red, green, and blue, respectively, for a pixel.
  85.  
  86. The biClrUsed member of the BITMAPINFOHEADER structure specifies the number
  87. of color indexes in the color table actually used by the bitmap. If the
  88. biClrUsed member is set to zero, the bitmap uses the maximum number of colors
  89. corresponding to the value of the biBitCount member.  An alternative form of
  90. bitmap file uses the BITMAPCOREINFO, BITMAPCOREHEADER, and RGBTRIPLE
  91. structures.
  92.  
  93. Bitmap Compression
  94.  
  95. Windows versions 3.0 and later support run-length encoded (RLE) formats for
  96. compressing bitmaps that use 4 bits per pixel and 8 bits per pixel.
  97. Compression reduces the disk and memory storage required for a bitmap.
  98.  
  99. Compression of 8-Bits-per-Pixel Bitmaps
  100.  
  101. When the biCompression member of the BITMAPINFOHEADER structure is set to
  102. BI_RLE8, the DIB is compressed using a run-length encoded format for a
  103. 256-color bitmap. This format uses two modes: encoded mode and absolute mode.
  104. Both modes can occur anywhere throughout a single bitmap.
  105.  
  106. Encoded Mode
  107.  
  108. A unit of information in encoded mode consists of two bytes. The first byte
  109. specifies the number of consecutive pixels to be drawn using the color index
  110. contained in the second byte.  The first byte of the pair can be set to zero
  111. to indicate an escape that denotes the end of a line, the end of the bitmap,
  112. or a delta. The interpretation of the escape depends on the value of the
  113. second byte of the pair, which must be in the range 0x00 through 0x02.
  114. Following are the meanings of the escape values that can be used in the
  115. second byte:
  116.  
  117. Second byte    Meaning
  118.  
  119. 0    End of line. 
  120. 1    End of bitmap. 
  121. 2    Delta. The two bytes following the escape contain unsigned values
  122. indicating the horizontal and vertical offsets of the next pixel from the
  123. current position.
  124.  
  125. Absolute Mode
  126.  
  127. Absolute mode is signaled by the first byte in the pair being set to zero and
  128. the second byte to a value between 0x03 and 0xFF. The second byte represents
  129. the number of bytes that follow, each of which contains the color index of a
  130. single pixel. Each run must be aligned on a word boundary.  Following is an
  131. example of an 8-bit RLE bitmap (the two-digit hexadecimal values in the
  132. second column represent a color index for a single pixel):
  133.  
  134. Compressed data        Expanded data
  135.  
  136. 03 04            04 04 04 
  137. 05 06            06 06 06 06 06 
  138. 00 03 45 56 67 00    45 56 67 
  139. 02 78            78 78 
  140. 00 02 05 01        Move 5 right and 1 down 
  141. 02 78            78 78 
  142. 00 00            End of line 
  143. 09 1E            1E 1E 1E 1E 1E 1E 1E 1E 1E 
  144. 00 01            End of RLE bitmap 
  145.  
  146. Compression of 4-Bits-per-Pixel Bitmaps
  147.  
  148. When the biCompression member of the BITMAPINFOHEADER structure is set to
  149. BI_RLE4, the DIB is compressed using a run-length encoded format for a
  150. 16-color bitmap. This format uses two modes: encoded mode and absolute mode.
  151.  
  152. Encoded Mode
  153.  
  154. A unit of information in encoded mode consists of two bytes. The first byte
  155. of the pair contains the number of pixels to be drawn using the color indexes
  156. in the second byte.
  157.  
  158. The second byte contains two color indexes, one in its high-order nibble
  159. (that is, its low-order 4 bits) and one in its low-order nibble.
  160.  
  161. The first pixel is drawn using the color specified by the high-order nibble,
  162. the second is drawn using the color in the low-order nibble, the third is
  163. drawn with the color in the high-order nibble, and so on, until all the
  164. pixels specified by the first byte have been drawn.
  165.  
  166. The first byte of the pair can be set to zero to indicate an escape that
  167. denotes the end of a line, the end of the bitmap, or a delta. The
  168. interpretation of the escape depends on the value of the second byte of the
  169. pair. In encoded mode, the second byte has a value in the range 0x00 through
  170. 0x02. The meaning of these values is the same as for a DIB with 8 bits per
  171. pixel.
  172.  
  173. Absolute Mode
  174.  
  175. In absolute mode, the first byte contains zero, the second byte contains the
  176. number of color indexes that follow, and subsequent bytes contain color
  177. indexes in their high- and low-order nibbles, one color index for each pixel.
  178. Each run must be aligned on a word boundary.
  179.  
  180. Following is an example of a 4-bit RLE bitmap (the one-digit hexadecimal
  181. values in the second column represent a color index for a single pixel):
  182.  
  183. Compressed data        Expanded data
  184.  
  185. 03 04            0 4 0 
  186. 05 06            0 6 0 6 0 
  187. 00 06 45 56 67 00    4 5 5 6 6 7 
  188. 04 78            7 8 7 8 
  189. 00 02 05 01        Move 5 right and 1 down 
  190. 04 78            7 8 7 8 
  191. 00 00            End of line 
  192. 09 1E            1 E 1 E 1 E 1 E 1 
  193. 00 01            End of RLE bitmap 
  194.  
  195. Bitmap Example
  196.  
  197. The following example is a text dump of a 16-color bitmap (4 bits per pixel):
  198.  
  199. Win3DIBFile
  200.               BitmapFileHeader
  201.                   Type       19778
  202.                   Size       3118
  203.                   Reserved1  0
  204.                   Reserved2  0
  205.                   OffsetBits 118
  206.               BitmapInfoHeader
  207.                   Size            40
  208.                   Width           80
  209.                   Height          75
  210.                   Planes          1
  211.                   BitCount        4
  212.                   Compression     0
  213.                   SizeImage       3000
  214.  
  215.                   XPelsPerMeter   0
  216.                   YPelsPerMeter   0
  217.                   ColorsUsed      16
  218.                   ColorsImportant 16
  219.               Win3ColorTable
  220.                   Blue  Green  Red  Unused
  221. [00000000]        84    252    84   0
  222. [00000001]        252   252    84   0
  223. [00000002]        84    84     252  0
  224. [00000003]        252   84     252  0
  225. [00000004]        84    252    252  0
  226. [00000005]        252   252    252  0
  227. [00000006]        0     0      0    0
  228. [00000007]        168   0      0    0
  229. [00000008]        0     168    0    0
  230. [00000009]        168   168    0    0
  231. [0000000A]        0     0      168  0
  232. [0000000B]        168   0      168  0
  233. [0000000C]        0     168    168  0
  234. [0000000D]        168   168    168  0
  235. [0000000E]        84    84     84   0
  236. [0000000F]        252   84     84   0
  237.               Image
  238.     .
  239.     .                                           Bitmap data
  240.     .
  241.  
  242. Icon-Resource File Format
  243.  
  244. An icon-resource file contains image data for icons used by Windows
  245. applications. The file consists of an icon directory identifying the number
  246. and types of icon images in the file, plus one or more icon images. The
  247. default filename extension for an icon-resource file is .ICO.
  248.  
  249. Icon Directory
  250.  
  251. Each icon-resource file starts with an icon directory. The icon directory,
  252. defined as an ICONDIR structure, specifies the number of icons in the
  253. resource and the dimensions and color format of each icon image. The ICONDIR
  254. structure has the following form:
  255.  
  256.  
  257.  
  258. typedef struct ICONDIR {
  259.     WORD          idReserved;
  260.     WORD          idType;
  261.     WORD          idCount;
  262.     ICONDIRENTRY  idEntries[1];
  263. } ICONHEADER;
  264.  
  265. Following are the members in the ICONDIR structure: 
  266.  
  267. idReserved    Reserved; must be zero. 
  268. idType        Specifies the resource type. This member is set to 1. 
  269. idCount        Specifies the number of entries in the directory. 
  270. idEntries    Specifies an array of ICONDIRENTRY structures containing
  271. information about individual icons. The idCount member specifies the number
  272. of structures in the array.
  273.  
  274. The ICONDIRENTRY structure specifies the dimensions and color format for an
  275. icon. The structure has the following form:
  276.  
  277.  
  278.  
  279. struct IconDirectoryEntry {
  280.     BYTE  bWidth;
  281.     BYTE  bHeight;
  282.     BYTE  bColorCount;
  283.     BYTE  bReserved;
  284.     WORD  wPlanes;
  285.     WORD  wBitCount;
  286.     DWORD dwBytesInRes;
  287.     DWORD dwImageOffset;
  288. };
  289.  
  290. Following are the members in the ICONDIRENTRY structure: 
  291.  
  292. bWidth        Specifies the width of the icon, in pixels. Acceptable values
  293. are 16, 32, and 64.
  294.  
  295. bHeight        Specifies the height of the icon, in pixels. Acceptable
  296. values are 16, 32, and 64.
  297.  
  298. bColorCount    Specifies the number of colors in the icon. Acceptable values
  299. are 2, 8, and 16.
  300.  
  301. bReserved    Reserved; must be zero. 
  302. wPlanes        Specifies the number of color planes in the icon bitmap. 
  303. wBitCount    Specifies the number of bits in the icon bitmap. 
  304. dwBytesInRes    Specifies the size of the resource, in bytes. 
  305. dwImageOffset    Specifies the offset, in bytes, from the beginning of the
  306. file to the icon image.
  307.  
  308. Icon Image
  309.  
  310. Each icon-resource file contains one icon image for each image identified in
  311. the icon directory. An icon image consists of an icon-image header, a color
  312. table, an XOR mask, and an AND mask. The icon image has the following form:
  313.  
  314.  
  315.  
  316. BITMAPINFOHEADER    icHeader;
  317. RGBQUAD             icColors[];
  318. BYTE                icXOR[];
  319. BYTE                icAND[];
  320.  
  321. The icon-image header, defined as a BITMAPINFOHEADER structure, specifies the
  322. dimensions and color format of the icon bitmap. Only the biSize through
  323. biBitCount members and the biSizeImage member are used. All other members
  324. (such as biCompression and biClrImportant) must be set to zero.
  325.  
  326. The color table, defined as an array of RGBQUAD structures, specifies the
  327. colors used in the XOR mask. As with the color table in a bitmap file, the
  328. biBitCount member in the icon-image header determines the number of elements
  329. in the array. For more information about the color table, see Section 1.1,
  330. "Bitmap-File Formats."
  331.  
  332. The XOR mask, immediately following the color table, is an array of BYTE
  333. values representing consecutive rows of a bitmap. The bitmap defines the
  334. basic shape and color of the icon image. As with the bitmap bits in a bitmap
  335. file, the bitmap data in an icon-resource file is organized in scan lines,
  336. with each byte representing one or more pixels, as defined by the color
  337. format. For more information about these bitmap bits, see Section 1.1,
  338. "Bitmap-File Formats."
  339.  
  340. The AND mask, immediately following the XOR mask, is an array of BYTE values,
  341. representing a monochrome bitmap with the same width and height as the XOR
  342. mask. The array is organized in scan lines, with each byte representing 8
  343. pixels.
  344.  
  345. When Windows draws an icon, it uses the AND and XOR masks to combine the icon
  346. image with the pixels already on the display surface. Windows first applies
  347. the AND mask by using a bitwise AND operation; this preserves or removes
  348. existing pixel color.  Windows then applies the XOR mask by using a bitwise
  349. XOR operation. This sets the final color for each pixel.
  350.  
  351. The following illustration shows the XOR and AND masks that create a
  352. monochrome icon (measuring 8 pixels by 8 pixels) in the form of an uppercase
  353. K:
  354.  
  355. Windows Icon Selection
  356.  
  357. Windows detects the resolution of the current display and matches it against
  358. the width and height specified for each version of the icon image. If Windows
  359. determines that there is an exact match between an icon image and the current
  360. device, it uses the matching image. Otherwise, it selects the closest match
  361. and stretches the image to the proper size.
  362.  
  363. If an icon-resource file contains more than one image for a particular
  364. resolution, Windows uses the icon image that most closely matches the color
  365. capabilities of the current display. If no image matches the device
  366. capabilities exactly, Windows selects the image that has the greatest number
  367. of colors without exceeding the number of display colors. If all images
  368. exceed the color capabilities of the current display, Windows uses the icon
  369. image with the least number of colors.
  370.  
  371.  
  372.  
  373. Cursor-Resource File Format
  374.  
  375. A cursor-resource file contains image data for cursors used by Windows
  376. applications. The file consists of a cursor directory identifying the number
  377. and types of cursor images in the file, plus one or more cursor images. The
  378. default filename extension for a cursor-resource file is .CUR.
  379.  
  380. Cursor Directory
  381.  
  382. Each cursor-resource file starts with a cursor directory. The cursor
  383. directory, defined as a CURSORDIR structure, specifies the number of cursors
  384. in the file and the dimensions and color format of each cursor image. The
  385. CURSORDIR structure has the following form:
  386.  
  387.  
  388. typedef struct _CURSORDIR {
  389.     WORD           cdReserved;
  390.     WORD           cdType;
  391.     WORD           cdCount;
  392.     CURSORDIRENTRY cdEntries[];
  393. } CURSORDIR;
  394.  
  395. Following are the members in the CURSORDIR structure: 
  396.  
  397. cdReserved    Reserved; must be zero. 
  398. cdType        Specifies the resource type. This member must be set to 2. 
  399. cdCount        Specifies the number of cursors in the file. 
  400. cdEntries    Specifies an array of CURSORDIRENTRY structures containing
  401. information about individual cursors. The cdCount member specifies the number
  402. of structures in the array.
  403.  
  404. A CURSORDIRENTRY structure specifies the dimensions and color format of a
  405. cursor image. The structure has the following form:
  406.  
  407.  
  408.  
  409. typedef struct _CURSORDIRENTRY {
  410.     BYTE  bWidth;
  411.     BYTE  bHeight;
  412.     BYTE  bColorCount;
  413.     BYTE  bReserved;
  414.     WORD  wXHotspot;
  415.     WORD  wYHotspot;
  416.     DWORD lBytesInRes;
  417.     DWORD dwImageOffset;
  418. } CURSORDIRENTRY;
  419.  
  420. Following are the members in the CURSORDIRENTRY structure: 
  421.  
  422. bWidth        Specifies the width of the cursor, in pixels. 
  423. bHeight        Specifies the height of the cursor, in pixels. 
  424. bColorCount    Reserved; must be zero. 
  425. bReserved    Reserved; must be zero. 
  426. wXHotspot    Specifies the x-coordinate, in pixels, of the hot spot. 
  427. wYHotspot    Specifies the y-coordinate, in pixels, of the hot spot. 
  428. lBytesInRes    Specifies the size of the resource, in bytes. 
  429. dwImageOffset    Specifies the offset, in bytes, from the start of the file to
  430. the cursor image.
  431.  
  432. Cursor Image
  433.  
  434. Each cursor-resource file contains one cursor image for each image identified
  435. in the cursor directory. A cursor image consists of a cursor-image header, a
  436. color table, an XOR mask, and an AND mask. The cursor image has the following
  437. form:
  438.  
  439.  
  440.  
  441. BITMAPINFOHEADER    crHeader;
  442. RGBQUAD             crColors[];
  443. BYTE                crXOR[];
  444. BYTE                crAND[];
  445.  
  446. The cursor hot spot is a single pixel in the cursor bitmap that Windows uses
  447. to track the cursor. The crXHotspot and crYHotspot members specify the x- and
  448. y-coordinates of the cursor hot spot. These coordinates are 16-bit integers.
  449.  
  450. The cursor-image header, defined as a BITMAPINFOHEADER structure, specifies
  451. the dimensions and color format of the cursor bitmap. Only the biSize through
  452. biBitCount members and the biSizeImage member are used. The biHeight member
  453. specifies the combined height of the XOR and AND masks for the cursor. This
  454. value is twice the height of the XOR mask. The biPlanes and biBitCount
  455. members must be 1. All other members (such as biCompression and
  456. biClrImportant) must be set to zero.
  457.  
  458. The color table, defined as an array of RGBQUAD structures, specifies the
  459. colors used in the XOR mask. For a cursor image, the table contains exactly
  460. two structures, since the biBitCount member in the cursor-image header is
  461. always 1.
  462.  
  463. The XOR mask, immediately following the color table, is an array of BYTE
  464. values representing consecutive rows of a bitmap. The bitmap defines the
  465. basic shape and color of the cursor image. As with the bitmap bits in a
  466. bitmap file, the bitmap data in a cursor-resource file is organized in scan
  467. lines, with each byte representing one or more pixels, as defined by the
  468. color format. For more information about these bitmap bits, see Section 1.1,
  469. "Bitmap-File Formats."
  470.  
  471. The AND mask, immediately following the XOR mask, is an array of BYTE values
  472. representing a monochrome bitmap with the same width and height as the XOR
  473. mask. The array is organized in scan lines, with each byte representing 8
  474. pixels.
  475.  
  476. When Windows draws a cursor, it uses the AND and XOR masks to combine the
  477. cursor image with the pixels already on the display surface. Windows first
  478. applies the AND mask by using a bitwise AND operation; this preserves or
  479. removes existing pixel color.  Window then applies the XOR mask by using a
  480. bitwise XOR operation. This sets the final color for each pixel.
  481.  
  482. The following illustration shows the XOR and the AND masks that create a
  483. cursor (measuring 8 pixels by 8 pixels) in the form of an arrow:
  484.  
  485. Following are the bit-mask values necessary to produce black, white,
  486. inverted, and transparent results:
  487.  
  488. Pixel result    AND mask    XOR mask
  489.  
  490. Black        0        0 
  491. White        0        1 
  492. Transparent    1        0 
  493. Inverted    1        1 
  494.  
  495. Windows Cursor Selection
  496.  
  497. If a cursor-resource file contains more than one cursor image, Windows
  498. determines the best match for a particular display by examining the width and
  499. height of the cursor images.
  500.  
  501.  
  502. ==============================================================================
  503.  
  504.  
  505. BITMAPFILEHEADER (3.0)
  506.  
  507.  
  508.  
  509. typedef struct tagBITMAPFILEHEADER {    /* bmfh */
  510.     UINT    bfType;
  511.     DWORD   bfSize;
  512.     UINT    bfReserved1;
  513.     UINT    bfReserved2;
  514.     DWORD   bfOffBits;
  515. } BITMAPFILEHEADER;
  516.  
  517. The BITMAPFILEHEADER structure contains information about the type, size, and
  518. layout of a device-independent bitmap (DIB) file.
  519.  
  520. Member        Description
  521.  
  522. bfType        Specifies the type of file. This member must be BM. 
  523. bfSize        Specifies the size of the file, in bytes. 
  524. bfReserved1    Reserved; must be set to zero. 
  525. bfReserved2    Reserved; must be set to zero. 
  526. bfOffBits    Specifies the byte offset from the BITMAPFILEHEADER structure
  527. to the actual bitmap data in the file.
  528.  
  529. Comments
  530.  
  531. A BITMAPINFO or BITMAPCOREINFO structure immediately follows the
  532. BITMAPFILEHEADER structure in the DIB file.
  533.  
  534. See Also
  535.  
  536. BITMAPCOREINFO, BITMAPINFO 
  537.  
  538.  
  539. ==============================================================================
  540. BITMAPINFO (3.0)
  541.  
  542.  
  543.  
  544. typedef struct tagBITMAPINFO {  /* bmi */
  545.     BITMAPINFOHEADER    bmiHeader;
  546.     RGBQUAD             bmiColors[1];
  547. } BITMAPINFO;
  548.  
  549. The BITMAPINFO structure fully defines the dimensions and color information
  550. for a Windows 3.0 or later device-independent bitmap (DIB).
  551.  
  552. Member        Description
  553.  
  554. bmiHeader    Specifies a BITMAPINFOHEADER structure that contains
  555. information about the dimensions and color format of a DIB.
  556.  
  557. bmiColors    Specifies an array of RGBQUAD structures that define the
  558. colors in the bitmap.
  559.  
  560. Comments
  561.  
  562. A Windows 3.0 or later DIB consists of two distinct parts: a BITMAPINFO
  563. structure, which describes the dimensions and colors of the bitmap, and an
  564. array of bytes defining the pixels of the bitmap. The bits in the array are
  565. packed together, but each scan line must be zero-padded to end on a LONG
  566. boundary. Segment boundaries, however, can appear anywhere in the bitmap. The
  567. origin of the bitmap is the lower-left corner.
  568.  
  569. The biBitCount member of the BITMAPINFOHEADER structure determines the number
  570. of bits which define each pixel and the maximum number of colors in the
  571. bitmap. This member may be set to any of the following values:
  572.  
  573. Value    Meaning
  574.  
  575. 1    The bitmap is monochrome, and the bmciColors member must contain two
  576. entries. Each bit in the bitmap array represents a pixel. If the bit is
  577. clear, the pixel is displayed with the color of the first entry in the
  578. bmciColors table. If the bit is set, the pixel has the color of the second
  579. entry in the table.
  580.  
  581. 4    The bitmap has a maximum of 16 colors, and the bmciColors member
  582. contains 16 entries. Each pixel in the bitmap is represented by a four-bit
  583. index into the color table.
  584.  
  585. For example, if the first byte in the bitmap is 0x1F, the byte represents two
  586. pixels. The first pixel contains the color in the second table entry, and the
  587. second pixel contains the color in the sixteenth table entry.
  588.  
  589. 8    The bitmap has a maximum of 256 colors, and the bmciColors member
  590. contains 256 entries. In this case, each byte in the array represents a
  591. single pixel.
  592.  
  593. 24    The bitmap has a maximum of 2^24 colors. The bmciColors member is
  594. NULL, and each 3-byte sequence in the bitmap array represents the relative
  595. intensities of red, green, and blue, respectively, of a pixel.
  596.  
  597. The biClrUsed member of the BITMAPINFOHEADER structure specifies the number
  598. of color indexes in the color table actually used by the bitmap. If the
  599. biClrUsed member is set to zero, the bitmap uses the maximum number of colors
  600. corresponding to the value of the biBitCount member.
  601.  
  602. The colors in the bmiColors table should appear in order of importance.
  603. Alternatively, for functions that use DIBs, the bmiColors member can be an
  604. array of 16-bit unsigned integers that specify an index into the currently
  605. realized logical palette instead of explicit RGB values. In this case, an
  606. application using the bitmap must call DIB functions with the wUsage
  607. parameter set to DIB_PAL_COLORS.
  608.  
  609. Note:    The bmiColors member should not contain palette indexes if the bitmap
  610. is to be stored in a file or transferred to another application. Unless the
  611. application uses the bitmap exclusively and under its complete control, the
  612. bitmap color table should contain explicit RGB values.
  613.  
  614. See Also
  615.  
  616. BITMAPINFOHEADER, RGBQUAD 
  617.  
  618. ==============================================================================
  619. BITMAPINFOHEADER (3.0)
  620.  
  621.  
  622.  
  623. typedef struct tagBITMAPINFOHEADER {    /* bmih */
  624.     DWORD   biSize;
  625.     LONG    biWidth;
  626.     LONG    biHeight;
  627.     WORD    biPlanes;
  628.     WORD    biBitCount;
  629.     DWORD   biCompression;
  630.     DWORD   biSizeImage;
  631.     LONG    biXPelsPerMeter;
  632.     LONG    biYPelsPerMeter;
  633.     DWORD   biClrUsed;
  634.     DWORD   biClrImportant;
  635. } BITMAPINFOHEADER;
  636.  
  637. The BITMAPINFOHEADER structure contains information about the dimensions and
  638. color format of a Windows 3.0 or later device-independent bitmap (DIB).
  639.  
  640. Member        Description
  641.  
  642. biSize        Specifies the number of bytes required by the
  643. BITMAPINFOHEADER structure.
  644.  
  645. biWidth        Specifies the width of the bitmap, in pixels. 
  646. biHeight    Specifies the height of the bitmap, in pixels. 
  647.  
  648. biPlanes    Specifies the number of planes for the target device. This
  649. member must be set to 1.
  650.  
  651. biBitCount    Specifies the number of bits per pixel. This value must be 1,
  652. 4, 8, or 24.
  653.  
  654. biCompression    Specifies the type of compression for a compressed bitmap. It
  655. can be one of the following values:
  656.  
  657. Value        Meaning
  658.  
  659. BI_RGB        Specifies that the bitmap is not compressed. 
  660.  
  661. BI_RLE8        Specifies a run-length encoded format for bitmaps with 8 bits
  662. per pixel. The compression format is a 2-byte format consisting of a count
  663. byte followed by a byte containing a color index.  For more information, see
  664. the following Comments section.
  665.  
  666. BI_RLE4        Specifies a run-length encoded format for bitmaps with 4 bits
  667. per pixel. The compression format is a 2-byte format consisting of a count
  668. byte followed by two word-length color indexes.  For more information, see
  669. the following Comments section.
  670.  
  671. biSizeImage    Specifies the size, in bytes, of the image. It is valid to
  672. set this member to zero if the bitmap is in the BI_RGB format.
  673.  
  674. biXPelsPerMeter    Specifies the horizontal resolution, in pixels per meter, of
  675. the target device for the bitmap. An application can use this value to select
  676. a bitmap from a resource group that best matches the characteristics of the
  677. current device.
  678.  
  679. biYPelsPerMeter    Specifies the vertical resolution, in pixels per meter, of
  680. the target device for the bitmap.
  681.  
  682. biClrUsed    Specifies the number of color indexes in the color table
  683. actually used by the bitmap. If this value is zero, the bitmap uses the
  684. maximum number of colors corresponding to the value of the biBitCount member.
  685. For more information on the maximum sizes of the color table, see the
  686. description of the BITMAPINFO structure earlier in this topic.
  687.  
  688. If the biClrUsed member is nonzero, it specifies the actual number of colors
  689. that the graphics engine or device driver will access if the biBitCount
  690. member is less than 24. If biBitCount is set to 24, biClrUsed specifies the
  691. size of the reference color table used to optimize performance of Windows
  692. color palettes.  If the bitmap is a packed bitmap (that is, a bitmap in which
  693. the bitmap array immediately follows the BITMAPINFO header and which is
  694. referenced by a single pointer), the biClrUsed member must be set to zero or
  695. to the actual size of the color table.
  696.  
  697. biClrImportant    Specifies the number of color indexes that are considered
  698. important for displaying the bitmap. If this value is zero, all colors are
  699. important.
  700.  
  701. Comments
  702.  
  703. The BITMAPINFO structure combines the BITMAPINFOHEADER structure and a color
  704. table to provide a complete definition of the dimensions and colors of a
  705. Windows 3.0 or later DIB. For more information about specifying a Windows 3.0
  706. DIB, see the description of the BITMAPINFO structure.
  707.  
  708. An application should use the information stored in the biSize member to
  709. locate the color table in a BITMAPINFO structure as follows:
  710.  
  711. pColor = ((LPSTR) pBitmapInfo + (WORD) (pBitmapInfo->bmiHeader.biSize))
  712.  
  713. Windows supports formats for compressing bitmaps that define their colors
  714. with 8 bits per pixel and with 4 bits per pixel. Compression reduces the disk
  715. and memory storage required for the bitmap. The following paragraphs describe
  716. these formats.
  717.  
  718. BI_RLE8
  719.  
  720. When the biCompression member is set to BI_RLE8, the bitmap is compressed
  721. using a run-length encoding format for an 8-bit bitmap. This format may be
  722. compressed in either of two modes: encoded and absolute. Both modes can occur
  723. anywhere throughout a single bitmap.
  724.  
  725. Encoded mode consists of two bytes: the first byte specifies the number of
  726. consecutive pixels to be drawn using the color index contained in the second
  727. byte. In addition, the first byte of the pair can be set to zero to indicate
  728. an escape that denotes an end of line, end of bitmap, or a delta. The
  729. interpretation of the escape depends on the value of the second byte of the
  730. pair. The following list shows the meaning of the second byte:
  731.  
  732. Value    Meaning
  733.  
  734. 0    End of line. 
  735. 1    End of bitmap. 
  736. 2    Delta. The two bytes following the escape contain unsigned values
  737. indicating the horizontal and vertical offset of the next pixel from the
  738. current position.
  739.  
  740. Absolute mode is signaled by the first byte set to zero and the second byte
  741. set to a value between 0x03 and 0xFF. In absolute mode, the second byte
  742. represents the number of bytes that follow, each of which contains the color
  743. index of a single pixel. When the second byte is set to 2 or less, the escape
  744. has the same meaning as in encoded mode. In absolute mode, each run must be
  745. aligned on a word boundary.  The following example shows the hexadecimal
  746. values of an 8-bit compressed bitmap:
  747.  
  748.  
  749.  
  750. 03 04 05 06 00 03 45 56 67 00 02 78 00 02 05 01
  751. 02 78 00 00 09 1E 00 01
  752.  
  753. This bitmap would expand as follows (two-digit values represent a color index
  754. for a single pixel):
  755.  
  756.  
  757.  
  758. 04 04 04
  759. 06 06 06 06 06
  760. 45 56 67
  761. 78 78
  762. move current position 5 right and 1 down
  763. 78 78
  764. end of line
  765. 1E 1E 1E 1E 1E 1E 1E 1E 1E
  766. end of RLE bitmap
  767.  
  768. BI_RLE4
  769.  
  770. When the biCompression member is set to BI_RLE4, the bitmap is compressed
  771. using a run-length encoding (RLE) format for a 4-bit bitmap, which also uses
  772. encoded and absolute modes. In encoded mode, the first byte of the pair
  773. contains the number of pixels to be drawn using the color indexes in the
  774. second byte. The second byte contains two color indexes, one in its
  775. high-order nibble (that is, its low-order four bits) and one in its low-order
  776. nibble. The first of the pixels is drawn using the color specified by the
  777. high-order nibble, the second is drawn using the color in the low-order
  778. nibble, the third is drawn with the color in the high-order nibble, and so
  779. on, until all the pixels specified by the first byte have been drawn.  In
  780. absolute mode, the first byte contains zero, the second byte contains the
  781. number of color indexes that follow, and subsequent bytes contain color
  782. indexes in their high- and low-order nibbles, one color index for each pixel.
  783. In absolute mode, each run must be aligned on a word boundary. The
  784. end-of-line, end-of-bitmap, and delta escapes also apply to BI_RLE4.
  785.  
  786. The following example shows the hexadecimal values of a 4-bit compressed
  787. bitmap:
  788.  
  789.  
  790.  
  791. 03 04 05 06 00 06 45 56 67 00 04 78 00 02 05 01
  792. 04 78 00 00 09 1E 00 01
  793.  
  794. This bitmap would expand as follows (single-digit values represent a color
  795. index for a single pixel):
  796.  
  797.  
  798.  
  799. 0 4 0
  800. 0 6 0 6 0
  801. 4 5 5 6 6 7
  802. 7 8 7 8
  803. move current position 5 right and 1 down
  804. 7 8 7 8
  805. end of line
  806. 1 E 1 E 1 E 1 E 1
  807. end of RLE bitmap
  808.  
  809. See Also
  810.  
  811. BITMAPINFO 
  812.  
  813. ==============================================================================
  814. RGBQUAD (3.0)
  815.  
  816.  
  817.  
  818. typedef struct tagRGBQUAD {     /* rgbq */
  819.     BYTE    rgbBlue;
  820.     BYTE    rgbGreen;
  821.     BYTE    rgbRed;
  822.     BYTE    rgbReserved;
  823. } RGBQUAD;
  824.  
  825. The RGBQUAD structure describes a color consisting of relative intensities of
  826. red, green, and blue. The bmiColors member of the BITMAPINFO structure
  827. consists of an array of RGBQUAD structures.
  828.  
  829. Member        Description
  830.  
  831. rgbBlue        Specifies the intensity of blue in the color. 
  832. rgbGreen    Specifies the intensity of green in the color. 
  833. rgbRed        Specifies the intensity of red in the color. 
  834. rgbReserved    Not used; must be set to zero. 
  835.  
  836. See Also
  837.  
  838. BITMAPINFO 
  839.  
  840. ==============================================================================
  841. RGB (2.x)
  842.  
  843. COLORREF RGB(cRed, cGreen, cBlue)
  844.  
  845. BYTE cRed;    /* red component of color    */
  846. BYTE cGreen;    /* green component of color    */
  847. BYTE cBlue;    /* blue component of color    */
  848.  
  849.  
  850. The RGB macro selects an RGB color based on the parameters supplied and the
  851. color capabilities of the output device.
  852.  
  853. Parameter    Description
  854.  
  855. cRed    Specifies the intensity of the red color field. 
  856. cGreen    Specifies the intensity of the green color field. 
  857. cBlue    Specifies the intensity of the blue color field. 
  858.  
  859. Returns
  860.  
  861. The return value specifies the resultant RGB color. 
  862.  
  863. Comments
  864.  
  865. The intensity for each argument can range from 0 through 255. If all three
  866. intensities are specified as zero, the result is black. If all three
  867. intensities are specified as 255, the result is white.
  868.  
  869. Comments
  870.  
  871. The RGB macro is defined in WINDOWS.H as follows: 
  872.  
  873.  
  874.  
  875. #define RGB(r,g,b)   ((COLORREF)(((BYTE)(r)|((WORD)(g)<<8))| \
  876.     (((DWORD)(BYTE)(b))<<16)))
  877.  
  878. See Also
  879.  
  880. GetBValue, GetGValue, GetRValue, PALETTEINDEX, PALETTERGB 
  881.  
  882. ==============================================================================
  883. BITMAPCOREINFO (3.0)
  884.  
  885.  
  886.  
  887. typedef struct tagBITMAPCOREINFO {  /* bmci */
  888.     BITMAPCOREHEADER bmciHeader;
  889.     RGBTRIPLE        bmciColors[1];
  890. } BITMAPCOREINFO;
  891.  
  892. The BITMAPCOREINFO structure fully defines the dimensions and color
  893. information for a device-independent bitmap (DIB).  Windows applications
  894. should use the BITMAPINFO structure instead of BITMAPCOREINFO whenever
  895. possible.
  896.  
  897. Member        Description
  898.  
  899. bmciHeader    Specifies a BITMAPCOREHEADER structure that contains
  900. information about the dimensions and color format of a DIB.
  901.  
  902. bmciColors    Specifies an array of RGBTRIPLE structures that define the
  903. colors in the bitmap.
  904.  
  905. Comments
  906.  
  907. The BITMAPCOREINFO structure describes the dimensions and colors of a bitmap.
  908. It is followed immediately in memory by an array of bytes which define the
  909. pixels of the bitmap. The bits in the array are packed together, but each
  910. scan line must be zero-padded to end on a LONG boundary. Segment boundaries,
  911. however, can appear anywhere in the bitmap. The origin of the bitmap is the
  912. lower-left corner.
  913.  
  914. The bcBitCount member of the BITMAPCOREHEADER structure determines the number
  915. of bits that define each pixel and the maximum number of colors in the
  916. bitmap. This member may be set to any of the following values:
  917.  
  918. Value    Meaning
  919.  
  920. 1    The bitmap is monochrome, and the bmciColors member must contain two
  921. entries. Each bit in the bitmap array represents a pixel. If the bit is
  922. clear, the pixel is displayed with the color of the first entry in the
  923. bmciColors table. If the bit is set, the pixel has the color of the second
  924. entry in the table.
  925.  
  926. 4    The bitmap has a maximum of 16 colors, and the bmciColors member
  927. contains 16 entries. Each pixel in the bitmap is represented by a four-bit
  928. index into the color table.
  929.  
  930. For example, if the first byte in the bitmap is 0x1F, the byte represents two
  931. pixels. The first pixel contains the color in the second table entry, and the
  932. second pixel contains the color in the sixteenth table entry.
  933.  
  934. 8    The bitmap has a maximum of 256 colors, and the bmciColors member
  935. contains 256 entries. In this case, each byte in the array represents a
  936. single pixel.
  937.  
  938. 24    The bitmap has a maximum of 2^24 colors. The bmciColors member is
  939. NULL, and each 3-byte sequence in the bitmap array represents the relative
  940. intensities of red, green, and blue, respectively, of a pixel.
  941.  
  942. The colors in the bmciColors table should appear in order of importance.
  943. Alternatively, for functions that use DIBs, the bmciColors member can be an
  944. array of 16-bit unsigned integers that specify an index into the currently
  945. realized logical palette instead of explicit RGB values. In this case, an
  946. application using the bitmap must call DIB functions with the wUsage
  947. parameter set to DIB_PAL_COLORS.
  948.  
  949. Note:    The bmciColors member should not contain palette indexes if the
  950. bitmap is to be stored in a file or transferred to another application.
  951. Unless the application uses the bitmap exclusively and under its complete
  952. control, the bitmap color table should contain explicit RGB values.
  953.  
  954. See Also
  955.  
  956. BITMAPINFO, BITMAPCOREHEADER, RGBTRIPLE 
  957.  
  958.  
  959. ==============================================================================
  960. BITMAPCOREHEADER (3.0)
  961.  
  962.  
  963.  
  964. typedef struct tagBITMAPCOREHEADER {    /* bmch */
  965.     DWORD   bcSize;
  966.     short   bcWidth;
  967.     short   bcHeight;
  968.     WORD    bcPlanes;
  969.     WORD    bcBitCount;
  970. } BITMAPCOREHEADER;
  971.  
  972. The BITMAPCOREHEADER structure contains information about the dimensions and
  973. color format of a device-independent bitmap (DIB). Windows applications
  974. should use the BITMAPINFOHEADER structure instead of BITMAPCOREHEADER
  975. whenever possible.
  976.  
  977. Member        Description
  978.  
  979. bcSize        Specifies the number of bytes required by the
  980. BITMAPCOREHEADER structure.
  981.  
  982. bcWidth        Specifies the width of the bitmap, in pixels. 
  983. bcHeight    Specifies the height of the bitmap, in pixels. 
  984.  
  985. bcPlanes    Specifies the number of planes for the target device. This
  986. member must be set to 1.
  987.  
  988. bcBitCount    Specifies the number of bits per pixel. This value must be 1,
  989. 4, 8, or 24.
  990.  
  991. Comments
  992.  
  993. The BITMAPCOREINFO structure combines the BITMAPCOREHEADER structure and a
  994. color table to provide a complete definition of the dimensions and colors of
  995. a DIB. See the description of the BITMAPCOREINFO structure for more
  996. information about specifying a DIB.
  997.  
  998. An application should use the information stored in the bcSize member to
  999. locate the color table in a BITMAPCOREINFO structure with a method such as
  1000. the following:
  1001.  
  1002.  
  1003.  
  1004. lpColor = ((LPSTR) pBitmapCoreInfo + (UINT) (pBitmapCoreInfo->bcSize))
  1005.  
  1006. See Also
  1007.  
  1008. BITMAPCOREINFO, BITMAPINFOHEADER, BITMAPINFOHEADER 
  1009.  
  1010. =============================================================================
  1011. RGBTRIPLE (3.0)
  1012.  
  1013.  
  1014.  
  1015. typedef struct tagRGBTRIPLE {   /* rgbt */
  1016.     BYTE    rgbtBlue;
  1017.     BYTE    rgbtGreen;
  1018.     BYTE    rgbtRed;
  1019. } RGBTRIPLE;
  1020.  
  1021. The RGBTRIPLE structure describes a color consisting of relative intensities
  1022. of red, green, and blue. The bmciColors member of the BITMAPCOREINFO
  1023. structure consists of an array of RGBTRIPLE structures.  Windows applications
  1024. should use the BITMAPINFO structure instead of BITMAPCOREINFO whenever
  1025. possible. The BITMAPINFO structure uses an RGBQUAD structure instead of the
  1026. RGBTRIPLE structure.
  1027.  
  1028. Member    Description
  1029.  
  1030. rgbtBlue    Specifies the intensity of blue in the color. 
  1031. rgbtGreen    Specifies the intensity of green in the color. 
  1032. rgbtRed        Specifies the intensity of red in the color. 
  1033.  
  1034. See Also
  1035.  
  1036. BITMAPCOREINFO, BITMAPINFO, RGBQUAD 
  1037.  
  1038. ==============================================================================
  1039.  
  1040.